package com.guaoran.java8concurrency.java5;

import com.sun.org.apache.xalan.internal.lib.ExsltBase;

import java.util.concurrent.*;

/**
 * @author : guaoran
 * @Description : <br/>
 *  对于Runnable Callable 有返回值
 * @date :2018/11/24 13:14
 */
public class CallableDemo {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        ExecutorService executorService = Executors.newFixedThreadPool(1);
        Future<String> future = executorService.submit(new Callable<String>() {
            @Override
            public String call() throws Exception {
                System.out.printf("[Thread Name :%s]start....\n", Thread.currentThread().getName());

                return "Hello world";
            }
        });
        String str = future.get();
        System.out.printf("[Thread Name :%s]....%s...\n", Thread.currentThread().getName(),str);
        executorService.shutdown();
    }
}
